﻿#include "changetip.h"
#include "ui_changetip.h"

ChangeTip::ChangeTip(QString tip,QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ChangeTip)
{
    ui->setupUi(this);

    //设置窗口无边框和背景透明
    this->setWindowFlags(Qt::WindowType::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
    setAttribute(Qt::WA_TranslucentBackground);

    QFont f;
    f.setBold(true);
    f.setFamily("黑体");
    f.setPointSize(15);

    this->setStyleSheet("color:blue");

    ui->label->setFont(f);
    this->resize(150,43);

    this->setCentralWidget(ui->label);
    ui->label->setText(tip);

    m_timer1.start(50);

    connect(&m_timer1,SIGNAL(timeout()),this,SLOT(onTimer1Out()));
}

ChangeTip::~ChangeTip()
{
    delete ui;
}

void ChangeTip::onTimer1Out()
{

    this->setWindowOpacity(this->windowOpacity() - 0.05);
    if(this->windowOpacity() < 0.05){
        m_timer1.stop();
        this->close();
        this->deleteLater();
    }
}
